package tpenchere.ui.verifier;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

public class NotBlankVerifier extends InputVerifier {
	
	@Override
	public boolean verify(JComponent input) {
		JTextField jt = (JTextField) input;
		Boolean isNotBlank = jt.getText() != null && !jt.getText().trim().equals("");
		
		if(!isNotBlank){
			jt.setBackground(Color.red);
		} else {
			try {
				jt.setBackground(input.getClass().newInstance().getBackground());
			} catch(Exception e) {}
			
		}
		
		return isNotBlank;
	}

}
